//package com.exam.controller;
//
//import com.baomidou.mybatisplus.core.metadata.IPage;
//import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
//import com.exam.entity.ApiResult;
//import com.exam.entity.Student;
//import com.exam.entity.User;
//import com.exam.serviceimpl.StudentServiceImpl;
//import com.exam.util.ApiResultHandler;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.web.bind.annotation.*;
//
//@RestController
//public class StudentController {
//
//    @Autowired
//    private StudentServiceImpl studentService;
//
//    @GetMapping("/students/{page}/{size}")
//    public ApiResult findAll(@PathVariable Integer page, @PathVariable Integer size) {
//        Page<User> userPage = new Page< >(page,size);
//        IPage<User> res = studentService.findAll(userPage);
//        return  ApiResultHandler.buildApiResult(200,"分页查询所有用户",res);
//    }
//
//    @GetMapping("/student/{username}")//根据用户名查询
//    public ApiResult findById(@PathVariable("username") String username) {
//        User res = studentService.findById(username);
//        if (res != null) {
//        return ApiResultHandler.buildApiResult(200,"请求成功",res);
//        } else {
//            return ApiResultHandler.buildApiResult(404,"查询的用户不存在",null);
//        }
//    }
//
//    @DeleteMapping("/student/{username}")//删除用户
//    public ApiResult deleteById(@PathVariable("username") String username) {
//        return ApiResultHandler.buildApiResult(200,"删除成功",studentService.deleteById(username));
//    }
//
//    @PutMapping("/studentPWD")
//    public ApiResult updatePwd(@RequestBody User user) {
//        studentService.updatePwd(user);
//        return ApiResultHandler.buildApiResult(200,"密码更新成功",null);
//    }
//    @PutMapping("/student")//编辑信息
//    public ApiResult update(@RequestBody User user) {
//        int res = studentService.update(user);
//        if (res != 0) {
//            return ApiResultHandler.buildApiResult(200,"更新成功",res);
//        }
//        return ApiResultHandler.buildApiResult(400,"更新失败",res);
//    }
//
//    @PostMapping("/student")
//    public ApiResult add(@RequestBody User user) {
//        int res = studentService.add(user);
//        if (res == 1) {
//            return ApiResultHandler.buildApiResult(200,"添加成功",null);
//        }else {
//            return ApiResultHandler.buildApiResult(400,"添加失败",null);
//        }
//    }
//}
